{% extends base %}

{% block head %}
<style>
    #console {
        width:100%;
        height:30em;
        background: black;
    }
    .console_text {
        color:#fff;
        font-family: consolas;
        font-size:1em;
    }
    #cursor {
        margin: 0px;
        padding: 0px;
        background: blue;
        font-size: 1em;
    }
</style>

<link rel="stylesheet" type="text/css" href="/static/lib/jquery.terminal/jquery.terminal-1.3.1.min.css">
{% end %}

{% block body %}

<div class="card">
    {% set title = "在线终端" %}
    {% include common/base_title.html %}
</div>

<div class="card">
    <div id="console"></div>
</div>

<script type="text/javascript" src="/static/lib/jquery.terminal/jquery.terminal-1.3.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    $("#console").terminal(function(command, term) {
        if (command.indexOf("calc ")>=0) {
            term.echo(eval(command.substring(4)));
        } else {            
            $.post("/system/command", {command: command}, function (data, status) {
                term.echo(data);
            }).fail(function (data) {
                console.log(data);
                term.exception("failed"+data, "error");
            });
        }
    });
});
</script>

{% end %}